//封装选择器
function $(selector){
    var c=selector.substring(0,1);//获取第一个字符
    if(c=="#"){
        return document.getElementById(selector.substring(1,selector.length));//返回相应的元素
    }else if(c == '.'){
        return document.getElementsByClassName(selector.substring(1,selector.length))
    }else{
        return document.getElementsByTagName(selector);
    }
}
let $$=(i)=>{
    return document.querySelectorAll(i)
}
//右上角 我的  
$('#myName').onmouseenter = ()=>{
    $('.selfUl')[0].style.display = 'block'
    $('#myName').style.borderBottom = '4px solid #5FB878';
    $('.icon-xiajiantou')[0].style.transform = 'rotate(' + 180 + 'deg)';
}
$('#myName').onmouseleave = ()=>{
    $('.selfUl')[0].style.display = 'none'
    $('#myName').style.borderBottom = 'none';
    $('.icon-xiajiantou')[0].style.transform = 'rotate(' + 0 + 'deg)';
}

//重置按钮
$('.refreshBtn')[0].onclick = ()=>{
    $('.refreshIco')[0].style.transform="rotate(360deg)"
    setTimeout(()=>{
        window.location.reload()
    },1000)
}

//侧边栏点击首页管理有伸展效果
// var navOpen = $('.navOpen')[0]
// $('.navLink')[2].onclick = ()=>{
//     if(subHeight >= 80){
//         cutSubHeight(navOpen)
//         $('.navOpen')[0].style.transform = `rotate(0deg)`
//     }else{
//         $('.navOpen')[0].style.transform = `rotate(-90deg)`
//         openSub(navOpen)
//     }
    
// }

let subHeight = 0
function openSub(whitch){
    if(subHeight < 80){
        subHeight += 1
        whitch.style.height = `${subHeight}px`
        timer = setTimeout(openSub,1)
    }else{
        clearTimeout(timer)
    }
}
function cutSubHeight(whitch){
    if(subHeight > 0){
        subHeight -= 1
        whitch.style.height = `${subHeight}px`
        timer = setTimeout(cutSubHeight,1)
    }else{
        clearTimeout(timer)
    }
}


//提示窗（第一个参数传是否成功true或者false，第二个参数传内容）
function tigs(i,yes){
    $('.tip')[0].style.opacity = '1'
    if(yes == true){
        $('.tip')[0].innerHTML = `<i class="iconfont icon-chenggong"></i>${i}`
    }else{
        $('.tip')[0].innerHTML = `<i class="iconfont icon-shibai"></i>${i}`
    }
    $('.tip')[0].style.top="200px"
    setTimeout(()=>{
        // $('.tip')[0].style.opacity="0"
        setTimeout(()=>{
            $('.tip')[0].style.top="-100px"
        },1000)
    },2000)
}
// tigs("test",true)

//左侧导航栏，二级栏目，点击二级栏目展开，function(i为点击的第几个navLinkA)
let showList=(i)=>{
    for(let j=0,len=navLink.length;j<len;j++){
        navLink[j].classList.remove('bc')
    }
    for(let j=0,len=bigList.length;j<len;j++){
        if(i==j){
            console.log(i);
            navLinkA[i].classList.add('bc')
            if(i!=1&&i!=2&&i!=4)bigList[i].style.height="123px"
            if(i==3)bigList[i].style.height='164px'
            continue;
        }
        navLinkA[j].classList.remove('bc')
        bigList[j].style.height="41px"
    }
}

let navLink=document.querySelectorAll('.navLink')
let bigList=document.querySelectorAll('.bigList')
let navLinkA=document.querySelectorAll('.navLinkA')
for(let i=0,len=bigList.length;i<len;i++){
    navLinkA[i].addEventListener('click',()=>{
        showList(i)
    })
}

